﻿using System.Windows;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.UnityExtensions;
using Services;
using Microsoft.Practices.Unity;
using RentAWorker.Management.Infrastructure;

namespace RentAWorker.Management.Shell
{
    internal class Bootstrapper : UnityBootstrapper
    {
        protected override void ConfigureContainer()
        {
            Container.AddNewExtension<TypeTrackingExtension.TypeTrackingUnityExtension>();
            Container.RegisterType<IShellView, Shell>(new ContainerControlledLifetimeManager());
            Container.RegisterType<IExtendableShell, Shell>(new ContainerControlledLifetimeManager());

            base.ConfigureContainer();
        }

        protected override DependencyObject CreateShell()
        {
            ShellPresenter presenter = Container.Resolve<ShellPresenter>();

            IShellView view = presenter.View;
            view.ShowView();

            return view as DependencyObject;
        }

        protected override IModuleCatalog GetModuleCatalog()
        {
            return new ConfigurationModuleCatalog();
        }
    }
}
